package com.qqtech.qquan.coupon.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.coupon.cache.CouponSysParamCache;
import com.qqtech.qquan.coupon.dao.CouponSysParamDao;
import com.qqtech.qquan.coupon.model.*;

@Service
public class CouponSysParamServiceImpl extends BaseServiceImpl<CouponSysParam>
		implements CouponSysParamService {
	public static final Logger log = LoggerFactory.getLogger(CouponSysParamServiceImpl.class);
	
	@Resource
	private CouponSysParamDao couponSysParamDao;
	
	@Resource
	private CouponSysParamCache couponSysParamCache;

	@Override
	protected BaseDao<CouponSysParam> getBaseDao() {
		return couponSysParamDao;
	}
	
	@Override
	public CouponSysParam getByKey(java.lang.String key) {
		return couponSysParamDao.getByKey(key);
	}

	@Override
	public CouponSysParamVo getByKeyValue(String key, String value) {
		CouponSysParamQuery couponSysParamQuery=new CouponSysParamQuery();
		couponSysParamQuery.setKey(key);
		couponSysParamQuery.setValue(value);
		List<CouponSysParamVo> list=couponSysParamDao.queryList(couponSysParamQuery);
		return list.get(0);
	}

	@Override
	public void clearAll() {
		couponSysParamCache.clearAll();
	}

	@Override
	public String getValue(String key) {
		return couponSysParamCache.get(key);
	}	
}